package com.ad2campaign.engine.rest;

import java.util.List;
/*
 * This class represent a restful action response.
 * It will get serialize and de-serialize during rest operation.
 * Yes this class is thread safe.
 * */
public class RestActionResponse 
{
	public static final RestActionResponse NO_NODE_AVAILABLE = new RestActionResponse(false,"No node available, request lost!!");
	public static final RestActionResponse NO_NODE_REACHABLE = new RestActionResponse(false,"Unable to connect any available node");

	
	private boolean status;
	private String responseMessage;
	private List<?> data;
	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
	public String getResponseMessage() {
		return responseMessage;
	}
	public void setResponseMessage(String responseMessage) {
		this.responseMessage = responseMessage;
	}
	public List<?> getData() {
		return data;
	}
	public void setData(List<?> data) {
		this.data = data;
	}
	@Override
	public String toString() {
		return "[responseMessage=" + responseMessage	+ ", status=" + status + "]";
	}
	public RestActionResponse(boolean status, String responseMessage) {
		super();
		this.status = status;
		this.responseMessage = responseMessage;
	}
	public RestActionResponse(boolean status, String responseMessage,
			List<?> data) {
		super();
		this.status = status;
		this.responseMessage = responseMessage;
		this.data = data;
	}
	public RestActionResponse() {
		super();
		// TODO Auto-generated constructor stub
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((responseMessage == null) ? 0 : responseMessage.hashCode());
		result = prime * result + (status ? 1231 : 1237);
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RestActionResponse other = (RestActionResponse) obj;
		if (responseMessage == null) {
			if (other.responseMessage != null)
				return false;
		} else if (!responseMessage.equals(other.responseMessage))
			return false;
		if (status != other.status)
			return false;
		return true;
	}
	
	
}
